const {
  req
} = require('../../utils/requests')

Page({

  /**
   * 页面的初始数据
   */
  data: {
    mid: '',
    gameStatus: [], //赛况
    teamInfo: {}, //球队信息
    maxPlayers: {}, //本场最佳
    matchVideoList: [], //热议
    videoSrc: 'https://apd-vlive.apdcdn.tc.qq.com/sports.tc.qq.com/B_9LhzPzw8agpeEeKUHV_JXtlBcfpLkBZOMy04TfzYUC4/gzc_1000102_0b53liajuaaa2aaprjkeojsmawwdtj6abhsa.f2.mp4?sdtfrom=v3010&guid=44894e4623e9fc0c0c2fcf1f2357fc16&vkey=683DA88117445936FC13B25CEA24213B66893811AE750D811A4D877C91E13DF08E166E640050400A4D9835D4347CE2AB3DC1123AC97634066AB3F41BD12E0843FAA5C54769BFC0FB0E3A36ED4F428469D1655C44E37CD2D6E3AEC06E67E648931CB87E139558C401A712DF2DF61CA16C9077BC793A4BCC559906325E31A629AD8CA45523234771F1&platform=2#t=0', //视频地址
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      mid: JSON.parse(options.mid)
    })
    this.init()
    this.getMatchVideoRelated()
  },
  init() {
    let self = this;
    wx.request({
      url: 'https://app.sports.qq.com/match/statDetail?mid=' + self.data.mid,
      method: "GET",
      success(res) {
        self.setData({
          gameStatus: res.data.data.stats[0],
          maxPlayers: res.data.data.stats[2],
          teamInfo: res.data.data.teamInfo
        })
        console.log(self.data.teamInfo);
      }
    })
  },
  // 获取热议
  getMatchVideoRelated() {
    let self = this;
    wx.request({
      url: 'https://app.sports.qq.com/match/matchVideoRelated?mid=' + self.data.mid,
      method: "GET",
      success(res) {
        self.setData({
          matchVideoList: res.data.data
        })
      }
    })
  },
  // 切换视频
  changeVideoPlays(e) {
    let playid = e.currentTarget.dataset.playid
    console.log(e.currentTarget.dataset.playid);
    req('https://matchweb.sports.qq.com/vip/webPlayer?vid=' + playid).then(res => {
      console.log(res);
    })
  },
  // 球队详情
  gotoTeam(e) {
    let playid = e.currentTarget.dataset.teamid
    wx.navigateTo({
      url: '../team/team?playid=' + playid,
    })
  },
  // 跳转到球员详情界面
  gotoplayerId(e) {
    let playerId = e.currentTarget.dataset.playid.playerId
    console.log(playerId);
    wx.redirectTo({
      url: '../playerInformation/playerInformation?playid=' + JSON.stringify(playerId)
    })
  }

})